﻿using MvvmCross.Wpf.Views;
using Sidvall.UI.Views;
using Sidvall.AuthorizationManager.UI.ViewModels;
using System.Windows;
using System.Windows.Controls;

namespace Sidvall.AuthorizationManager.UI.Wpf.Views
{
	public partial class DocumentationView : MvxWpfView, IViewModelProvider
	{
		#region Public Members

		public new DocumentationViewModel ViewModel
		{
			get
			{
				return (DocumentationViewModel)base.ViewModel;
			}
			set
			{
				base.ViewModel = value;
			}
		}

		Sidvall.UI.ViewModels.IViewModel IViewModelProvider.ViewModel
		{
			get
			{
				return this.ViewModel;
			}
		}

		#endregion
		#region Constructors

		public DocumentationView()
		{
			InitializeComponent();
		}

		#endregion

		#region WebBrowser - set/get value

		public static readonly DependencyProperty HtmlProperty = DependencyProperty.RegisterAttached("Html", typeof(string), typeof(DocumentationView),
			new FrameworkPropertyMetadata(OnHtmlChanged));

		[AttachedPropertyBrowsableForType(typeof(WebBrowser))]
		public static string GetHtml(WebBrowser d)
		{
			return (string)d.GetValue(HtmlProperty);
		}
		public static void SetHtml(WebBrowser d, string value)
		{
			d.SetValue(HtmlProperty, value);
		}
		static void OnHtmlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			WebBrowser wb = d as WebBrowser;
			if (wb != null)
				wb.NavigateToString(e.NewValue as string);
		}

		#endregion
	}
}
